const { safeArea, safeAreaInsets } = uni.getWindowInfo()
const ratio = 750 / safeArea.width
const area = {
  ratio,
  width: safeArea.width,
  height: safeArea.height,
  top: safeAreaInsets.top * ratio,
  top2: safeAreaInsets.top * ratio,
  bottom: safeAreaInsets.bottom * ratio * 0.5,
}

const menuButtonRect: { [key: string]: number } = {
  width: 0,
  height: 0,
  top: 0,
  right: 0,
  bottom: 0,
  left: 0,
}

// #ifdef MP
const rect: any = uni.getMenuButtonBoundingClientRect()

for (const key in menuButtonRect) {
  menuButtonRect[key] = rect[key] * ratio
}

area.top2 = rect.bottom * ratio
// #endif

let safeTop = 0

// #ifdef WEB
safeTop = area.top + 10
// #endif

// #ifdef MP-WEIXIN
safeTop = area.top2 - 80
// #endif

// #ifdef APP
safeTop = area.top
// #endif

/** 底部菜单安全距离 */
const safeBottom = area.bottom + 'rpx'

export { area as safeArea, safeAreaInsets, menuButtonRect, safeBottom, safeTop }
